<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/11/14 10:21
 * Desc: 退款规则工厂
 */
class Service_Refund_Rule_Factory
{
    /**
     * @description 退款规则工厂方法
     * @param $type_id
     * @return service_line_refund_rule|service_tuan_refund_rule|service_hotel_refund_rule|service_spot_refund_rule|service_car_refund_rule|service_outdoor_refund_rule|Service_Food_Refund_Rule|null
     */
    public static function get_instance($type_id)
    {
        $pinyin = DB::select('pinyin')
            ->from('model')
            ->where('id', '=', $type_id)
            ->execute()
            ->get('pinyin');
        if($pinyin) {
            $class_name = 'service_'.$pinyin.'_refund_rule';
            if (class_exists($class_name)) {
                return new $class_name();
            }
        }
        return null;
    }
}